// hoisting
console.log(a) // undefined
var a = 1


var a = 10
var a
console.log(a)


// 函数同样会提升（整个函数挪到作用域顶部），并且优先于变量
console.log(a) // ƒ a() {}
function a() { }
var a = 1


var a = 1
let b = 1
const c = 1
console.log(window.a) // 1
console.log(window.b) // undefined
console.log(window.c) // undefined

function test() {
  // cant hoisting
  console.log(a)
  let a
}
test()



// why hoisting
function test1() {
  test2()
}
function test2() {
  test1()
}
test1()